﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ECRMS.WinForm.WinService;
using ECRMS.WinForm.Modules;

namespace ECRMS.WinForm.BaseClass.Common
{
    public class ReportOfDesign
    {
        public List<CtReport> Reports;
        public CtReport OperatorRow;

        public FuncResult GetReports(Guid corpId)
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResultOfArrayOfCtReportOUJwPUXg result = ser.CtGetReoprts(corpId);

                if (result.Status == 1)
                {
                    this.Reports = (from a in result.Data orderby a.SeqId select a).ToList();
                }
                return new FuncResult
                {
                    Message = result.Message,
                    Status = result.Status
                };
            }
        }

        //得到某个员工的报表模块集合
        public FuncResult GetReportsByEmployee(Guid corpId,Guid employeeId)
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResultOfArrayOfCtReportOUJwPUXg result = ser.CtGetReoprtsByEmployeId(corpId, employeeId);

                if (result.Status == 1)
                {
                    this.Reports = (from a in result.Data orderby a.SeqId select a).ToList();
                }
                return new FuncResult
                {
                    Message = result.Message,
                    Status = result.Status
                };
            }
        }
        //管理员的报表模块集合
        public FuncResult GetReportsByEmployee(Guid corpId)
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResultOfArrayOfCtReportOUJwPUXg result = ser.CtGetReoprts(corpId);

                if (result.Status == 1)
                {
                    this.Reports = (from a in result.Data orderby a.SeqId select a).ToList();
                }
                return new FuncResult
                {
                    Message = result.Message,
                    Status = result.Status
                };
            }
        }

        public FuncResult UpdateReports()
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResult result = ser.CtUpdateReports(Reports);

                return new FuncResult
                {
                    Message = result.Message,
                    Status = result.Status
                };
            }
        }

    }
}
